
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />

<title>Bar Meter</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<link rel="stylesheet" href="docs.css">
</head>
<body>
<div class="container-fluid">
  <script src="menu.js"></script>
  <div class="content p-3">
    <div class="container-fluid">
      <h2>Bar Meter</h2>
      <hr>
      <canvas id="bar-meter" width="100" height="200"></canvas>

      <h5 class="mt-3">Html</h5>
  <pre><code><!-- Default view dimension 100 x 200 -->
<canvas id="bar-meter" width="100" height="200"></canvas></code></pre>

      <h5>JavaScript</h5>
<pre><code>/* Options */
var options = {
  // Minimum number.
  min: -100,
  // Maximum number.
  max: 100,
  // Background dash color.
  dashColor: '#e5e5e5',
  // Bar color.
  barColor: '#007bfb',
  // Bar speed.
  speed: 10,
  // Bar color gradient or not.
  gradient: true
};

/* Constructor */
var barMeter = new zeu.BarMeter('bar-meter', options);

/* Setter */
barMeter.value = 0;
barMeter.dashColor = '#e5e5e5';
barMeter.barColor = '#007bfb';
barMeter.speed = 5;</code></pre>

    <h4>More examples</h4>
    <p>
      Change bar color and speed based on the value.
    </p>
    <canvas id="bar-meter-2" width="100" height="200"></canvas>
    </div>
  </div>
</div>

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.4.0/styles/github.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.4.0/highlight.min.js"></script>
<script src="docs.js"></script>
<script src="../dist/zeu.js"></script>
<script type="text/javascript">

var options = {
  // Minimum number value.
  min: -100,
  // Maximum number value.
  max: 100,
  // Background dash hex color code.
  dashColor: '#e5e5e5',
  // Bar hex color code.
  barColor: '#007bfb',
  // Bar speed.
  speed: 10,
  // Bar color gradient or not.
  gradient: true,
  // Padding space of the bar.
  space: 20,
};

/* Constructor */
var barMeter = new zeu.BarMeter('bar-meter', options);

/* Setter */
barMeter.value = 0;


var barMeter2 = new zeu.BarMeter('bar-meter-2', {
  min: 0,
  max: 100,
  dashColor: COLOR.lightGrey
});

setInterval(function() {
  updateMeter();
}, 3000);

function updateMeter() {
  var value = getRandomInt(1, 100);
  barMeter2.value = value;
  if (value <= 30) {
    barMeter2.speed = 5;
    barMeter2.barColor = COLOR.green;
  } else if (value >= 60) {
    barMeter2.speed = 25;
    barMeter2.barColor = COLOR.red;
  } else {
    barMeter2.speed = 10;
    barMeter2.barColor = COLOR.yellow;
  }
}

updateMeter();


</script>
</body>
</html>

